#include <stdio.h>
#include <string.h>
struct  weapon
{
    /* data */
    char name[20];
    int atk;
    int price;
} weapon2;



int main(){
    struct weapon weapon1;
    weapon2.atk=1;
    strcpy(weapon2.name,"抢");
    weapon2.price = 200;
    printf("name:%s,atk:%d,price:%d\n",weapon2.name,weapon2.atk,weapon2.price);
    struct weapon weapon3 = {"weapon",100,200};

    printf("%s\n",weapon3.name);

    //struct weapon weapons[2] = {"w1",1,100,"w2",2,200};
    struct weapon weapons[2] = {{"w1",1,100},{"w2",2,200}};
    printf("name:%s,atk:%d,price:%d\n",weapons[0].name,weapons[0].atk,weapons[0].price);
    printf("name:%s,atk:%d,price:%d\n",weapons[1].name,weapons[1].atk,weapons[1].price);

    //结构体指针
    struct weapon *w;
    w = &weapon2;
    printf("name:%s,atk:%d,price:%d\n",(*w).name,(*w).atk,(*w).price);
    printf("name:%s,atk:%d,price:%d\n",w->name,w->atk,w->price);

    //结构体指针数组
    struct weapon *w2;
    w2 = weapons;
    printf("name:%s,atk:%d,price:%d\n",w2->name,w2->atk,w2->price); 
    printf("name:%s,atk:%d,price:%d\n",(*(w2+1)).name,(*(w2+1)).atk,(*(w2+1)).price);
    printf("name:%s,atk:%d,price:%d\n",(w2+1)->name,(w2+1)->atk,(w2+1)->price);
    printf("%d\n",sizeof(*w2));
    return 0;
}